# -*- coding: utf-8 -*-
import time
import os


def write_job(db_inst, job_id, prog, step, extra):
    pid = os.getpid()
    db_inst["jobs"].update_one({"_id": job_id},
                               {"$set": {"prog": str(prog), "step": step, "extra": extra, "update_time": int(time.time()), "pid": pid}})


def write_job_over(db_inst, job_id, status=True):
    db_inst["jobs"].update_one({"_id": job_id},
                               {"$set": {"status": status, "update_time": int(time.time())}})
